﻿using System;
using System.Web.Mvc;
using System.Web.WebPages;
using DNT.RavenQA.Core.Extensions;
using DNT.RavenQA.Core.Models;
using log4net;
using Raven.Client;

namespace DNT.RavenQA.Web.Controllers
{
    public abstract class ControllerBase : Controller
    {
        protected ControllerBase(IDocumentSession session, ILog log)
        {
            session.EnsureIsNotNull("session");
            _session = session;

            log.EnsureIsNotNull("log");
            _log = log;
        }

        protected IDocumentSession DocumentSession
        {
            get { return _session; }
        }
        private readonly IDocumentSession _session;

        protected ILog Log
        {
            get { return _log; }
        }
        private readonly ILog _log;

        protected virtual User CurrentUser
        {
            get { return User as User; }
        }

        protected Boolean IsLocalUrl(String url)
        {
            return Request.IsUrlLocalToHost(url);
        }
    }
}